package leetcode.datastructure.array;

import java.util.LinkedList;
import java.util.Queue;

public class Program27RemoveElement {
    public Program27RemoveElement() {
    }

    public int removeElement(int[] nums, int val) {
        if (nums.length == 0) {
            return 0;
        }
        int k = 0;
        int index = 0, i = 0;
        while (i < nums.length) {
            if (nums[i] != val) {
                nums[index++] = nums[i];
                ++k;
            }
            i++;
        }
        return k;
    }

    public static void main(String[] args) {
        Program27RemoveElement myStack = new Program27RemoveElement();
//        int[] nums = new int[]{0,1,2,2,3,0,4,2};
        int[] nums = new int[]{3,2,2,3};
        System.out.println(myStack.removeElement(nums, 3)); // 返回
    }
}
